/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vamprest;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author sav
 */
@Entity
@Table(name = "poi")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Poi.findAll", query = "SELECT p FROM Poi p"),
    @NamedQuery(name = "Poi.findByIdpoi", query = "SELECT p FROM Poi p WHERE p.idpoi = :idpoi"),
    @NamedQuery(name = "Poi.findByBegindatetime", query = "SELECT p FROM Poi p WHERE p.begindatetime = :begindatetime"),
    @NamedQuery(name = "Poi.findByEnddatetime", query = "SELECT p FROM Poi p WHERE p.enddatetime = :enddatetime")})
public class Poi implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "idpoi")
    private Integer idpoi;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "title")
    private String title;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "description")
    private String description;
    @Basic(optional = false)
    @Column(name = "ispublic")
    private int ispublic;
    @Column(name = "begindatetime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date begindatetime;
    @Column(name = "enddatetime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date enddatetime;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idpoi")
    private List<Link> links;
    @JoinColumn(name = "idmember", referencedColumnName = "idmember")
    @ManyToOne(optional = false)
    private Member idmember;
    @JoinColumn(name = "idaddress", referencedColumnName = "iddadress")
    @ManyToOne
    private Address idaddress;
    @JoinColumn(name = "idtheme", referencedColumnName = "idtheme")
    @ManyToOne(optional = false)
    private Theme idtheme;
    @Column(name = "imgurl")
    private String imgurl;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idpoi")
    private List<Poicomment> poicomments;

    public Poi() {
    }

    public Poi(Integer idpoi) {
        this.idpoi = idpoi;
    }

    public Poi(Integer idpoi, String title, String description, int ispublic) {
        this.idpoi = idpoi;
        this.title = title;
        this.description = description;
        this.ispublic = ispublic;
    }

    public Integer getIdpoi() {
        return idpoi;
    }

    public void setIdpoi(Integer idpoi) {
        this.idpoi = idpoi;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getIspublic() {
        return ispublic;
    }

    public void setIspublic(int ispublic) {
        this.ispublic = ispublic;
    }

    public Date getBegindatetime() {
        return begindatetime;
    }

    public void setBegindatetime(Date begindatetime) {
        this.begindatetime = begindatetime;
    }

    public Date getEnddatetime() {
        return enddatetime;
    }

    public void setEnddatetime(Date enddatetime) {
        this.enddatetime = enddatetime;
    }

    @XmlTransient
    public List<Link> getLinks() {
        return links;
    }

    public void setLinks(List<Link> links) {
        this.links = links;
    }

    public Member getIdmember() {
        return idmember;
    }

    public void setIdmember(Member idmember) {
        this.idmember = idmember;
    }

    public Address getIdaddress() {
        return idaddress;
    }

    public void setIdaddress(Address idaddress) {
        this.idaddress = idaddress;
    }

    public Theme getIdtheme() {
        return idtheme;
    }

    public void setIdtheme(Theme idtheme) {
        this.idtheme = idtheme;
    }

    public String getImgurl() {
        return imgurl;
    }

    public void setImgurl(String imgurl) {
        this.imgurl = imgurl;
    }

    @XmlTransient
    public List<Poicomment> getPoicomments() {
        return poicomments;
    }

    public void setPoicomments(List<Poicomment> poicomments) {
        this.poicomments = poicomments;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idpoi != null ? idpoi.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Poi)) {
            return false;
        }
        Poi other = (Poi) object;
        if ((this.idpoi == null && other.idpoi != null) || (this.idpoi != null && !this.idpoi.equals(other.idpoi))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "vamprest.Poi[ idpoi=" + idpoi + " ]";
    }

}
